﻿namespace LiteBlog.Infrastructure.Constraints
{
    using System.Web;
    using System.Web.Routing;

    public class PostConstraint : IRouteConstraint
    {
        public bool Match(
            HttpContextBase httpContext,
            Route route,
            string parameterName,
            RouteValueDictionary values,
            RouteDirection routeDirection)
        {
            if (parameterName == "id")
            {
                string id = values["id"].ToString();

                switch (id.ToLower())
                {
                    case "compose":
                    case "manage":
                    case "getmore":
                    case "delete":
                    case "create":
                    case "update":
                    case "approve":
                    case "reject":
                    case "save":
                    case "getpost":
                    case "publish":
                    case "upload":
                    case "deleteattachment":
                        return false;
                    default:
                        return true;
                }
            }

            return true;
        }
    }
}